package test

import (
	"fmt"
	"net/url"

	"databasex/dbx"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = DescribeTable("mongo",
	func(set dbx.MongoDB) {
		dsnx := set.URL(url.Values{})
		fmt.Println(dsnx.String())
		fmt.Println(set.DSN(url.Values{}))

		Expect(dsnx.String()).To(Equal(set.DSN(url.Values{})))
		return
	},
	Entry("normal", dbx.MongoDB{
		UserName: "UserName",
		Password: "Password",
		Addrs:    []string{"192.168.11.5:9000", "192.168.11.6:9000"},
		DBName:   "db",
	}),
	Entry("RsName", dbx.MongoDB{
		RsName:   "rs0",
		UserName: "UserName",
		DBName:   "db",
		Password: "Password",
		Addrs:    []string{"192.168.11.5:9000", "192.168.11.6:9000"},
	}),
	Entry("authMechanism", dbx.MongoDB{
		RsName:        "rs0",
		UserName:      "UserName",
		DBName:        "db",
		Password:      "Password",
		Addrs:         []string{"192.168.11.5:9000", "192.168.11.6:9000"},
		AuthMechanism: "SCRAM-SHA-256",
		Ssl:           dbx.TLS{},
	}),
)
